package alpha.unibratec;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.TextView;

public class PartidaActivity extends Activity implements OnClickListener {

	private Button but_acerto;
	private Button but_pulo;
	private Button but_erro;
	private Chronometer cronometro;
	private TextView txv_senha;
	/*private ImageView img_senha1;
	private ImageView img_senha2;
	private ImageView img_senha3;
	private ImageView img_senha4;
	private ImageView img_senha5;*/

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tela_partida);

		but_acerto = (Button) findViewById(R.id.but_acerto);
		but_pulo = (Button) findViewById(R.id.but_pulo);
		but_erro = (Button) findViewById(R.id.but_erro);
		but_acerto.setOnClickListener(this);
		but_pulo.setOnClickListener(this);
		but_erro.setOnClickListener(this);
		
		txv_senha = (TextView) findViewById(R.id.txv_senha);
		cronometro = (Chronometer) findViewById(R.id.cronometro);
		cronometro.setBase(SystemClock.elapsedRealtime());
		cronometro.start();

		/*img_senha1 = (ImageView) findViewById(R.id.img_senha1);
		img_senha2 = (ImageView) findViewById(R.id.img_senha2);
		img_senha3 = (ImageView) findViewById(R.id.img_senha3);
		img_senha4 = (ImageView) findViewById(R.id.img_senha4);
		img_senha5 = (ImageView) findViewById(R.id.img_senha5);*/
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		//for (int num_senha = 0; num_senha < 5; num_senha++) {
		
		ImageView img_senha1 = (ImageView) findViewById(R.id.img_senha1);
		
			switch (v.getId()) {
			case R.id.but_acerto:
				cronometro.stop();
				img_senha1.setImageResource(R.drawable.iconeacertou);
				proximaSenha();
				//Toast.makeText(this, "ACERTOU!! =)", Toast.LENGTH_SHORT).show();
				break;
			case R.id.but_pulo:
				img_senha1.setImageResource(R.drawable.iconepulou);
				cronometro.stop();
				proximaSenha();
				//Toast.makeText(this, "PULANDO NEH?!! o.O", Toast.LENGTH_SHORT).show();
				break;
			case R.id.but_erro:
				img_senha1.setImageResource(R.drawable.iconeerrou);
				cronometro.stop();
				cronometro.setText("00:00");
				proximaSenha();
				//Toast.makeText(this, "ERROU!! =(", Toast.LENGTH_SHORT).show();
				break;
			default:
				break;
			}
		//}
	}
	
	public void proximaSenha() {
		txv_senha.setText("M U S E U");
		cronometro.start();
	}
}
